﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autofac;
using Autofac.Builder;

namespace IOC.Autofac.Sample
{

    /// <summary>
    /// 
    /// </summary>
    class Program
    {

        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            Console.Title = "IOC,Autofac示例程序 www.lichaoqiang.com ";
            //容器生成器
            ContainerBuilder containerBuilder = new ContainerBuilder();

            //注册类型
            containerBuilder.RegisterType<Support.User>().As<Service.IUser>();
           
            IContainer container = containerBuilder.Build();//生成容器

            Service.IUser userService = container.Resolve<Service.IUser>();

            Domain.User user = userService.GetUserById(id: 1);

            Console.WriteLine("ok!");
            Console.ReadLine();
        }
    }
}
